<!DOCTYPE html>
<html lang="zh-cn">

<head>
<meta name="keywords" content="">
<meta name="description" content="">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>忘记密码-西安黑咖啡网络科技有限公司</title>
<link rel="stylesheet" href="http://temp.xablackcoffee.com/css/swiper.min.css">
<link rel="stylesheet" href="http://temp.xablackcoffee.com/css/font.css">
<link rel="stylesheet" href="http://temp.xablackcoffee.com/css/head.css">
<link rel="stylesheet" href="http://temp.xablackcoffee.com/css/nav.css">
<link rel="stylesheet" href="http://temp.xablackcoffee.com/css/swiper.min.css">
<link rel="stylesheet" href="http://temp.xablackcoffee.com/css/footer.css">
<link rel="stylesheet" href="http://temp.xablackcoffee.com/css/forgotpassword/forgotPassword.css">
<link rel="stylesheet" href="../css/forgotPassword.css">
<script type="text/javascript" src="http://temp.xablackcoffee.com/js/jquery.min.js"></script>
<script type="text/javascript" src="http://temp.xablackcoffee.com/js/swiper.min.js"></script>
<script type="text/javascript" src="http://temp.xablackcoffee.com/js/forgotpassword/forgotPassword.js"></script>
<script type="text/javascript" src="./bundle.js"></script>
<script type="text/javascript" src="../js/swiper.min.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/forgotPassword.js"></script>
<script type="text/javascript" src="../js/nav.js"></script>
<script type="text/javascript" src="../js/footer.js"></script>
</head>

<body>
    <div class="containers">
        <!-- 中间 -->
        <nav>
            <div class="wrap">
                <div class="container">
                    <div class='title'>修改密码</div>
                    <form action="">
                        <div class="box active">
                            <div onclick="changTab(event)">
                                <span class="icon iconfont icontongxunlu"></span> <span class="line"></span>
                                <input type="text" placeholder="请输入手机号" maxlength="11" class="inputs" id="phone">
                            </div>
                        </div>
                        <div class="box">
                            <div onclick="changTab(event)">
                                <span class="icon iconfont iconmima"></span> <span class="line"></span>
                                <input type="text" placeholder="请输入验证码" class="inputs" id="checkcode" maxlength="6"
                                    onblur="checkPassCode()">
                                <span class="checkcode" id="getCode" onclick="getCheckCode()">获取验证码</span>
                            </div>
                        </div>
                        <div class="box">
                            <div onclick="changTab(event)">
                                <span class="icon iconfont iconmima"></span> <span class="line"></span>
                                <input type="password" placeholder="请设置密码" class="inputs" id="password">
                            </div>
                        </div>
                        <div style="text-align:center;">
                            <div class="submit" onclick="resetPassword()">修改密码</div>
                        </div>
                    </form>

                </div>

            </div>
        </nav>
    </div>

    <!-- 尾部 -->
    <footer>
        <div class="footer">
            <div class="footer-container">
                <div class="left">
                    <div class="footer-titles">售前咨询</div>
                    <div class="footer-containers">400-0168-029</div>
                    <div class="footer-containers">专业技术咨询</div>
                    <div class="footer-containers">全方位产品解读</div>
                    <div class="footer-containers">成熟解决方案</div>
                    <div class="footer-containers">成功客户案例分享</div>
                </div>
                <div class="middle">
                    <ul>
                        <li class="footer-titles">支持与服务</li>
                        <li class="footer-containers"><a href="serviceItems.html" target="_self">服务项目</a></li>
                        <li class="footer-containers"><a href="case.html" target="_self">案例</a></li>
                        <li class="footer-containers"><a href="product.html" target="_self">产品</a></li>
                    </ul>
                    <ul>
                        <li class="footer-titles">资讯</li>
                        <li class="footer-containers"><a href="information.html" target="_self">资讯</a></li>
                    </ul>
                    <ul>
                        <li class="footer-titles">常见问题</li>
                        <li class="footer-containers"><a href="commonProblem.html" target="_self">常见问题</a></li>
                    </ul>
                    <ul>
                        <li class="footer-titles">关于我们</li>
                        <li class="footer-containers"><a href="aboutus.html" target="_self">关于我们</a></li>
                    </ul>
                </div>
                <div class="right">
                    <div class="footer-titles">关注黑咖啡</div>
                    <img src="image/index/er.png" alt="" style="width:80px;height:80px;">
                </div>
            </div>
            <div class="footer-me">
                <p>版权所有：©2018，西安黑咖啡网络科技有限公司保留所有权力陕ICP<a
                        href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=18005715">备案18005715号</a></p>
                <p>地址：西安市碑林区南稍门中贸广场2单元2307</p>
            </div>
            <div style="position:fixed;bottom:0px;left:0px;z-index:99999999999">
                <span class="icon iconfont iconkefu" style="margin-left:10px;cursor:pointer;color:#fff"
                    onclick="showModel()"></span>
            </div>
        </div>
        <div id="service">
            <iframe src="customerService.html" frameborder="0" id="frams"></iframe>
        </div>
    </footer>
</body>
<script type="text/javascript">
    var page = window.pageVariable.ForgotPassword;
    var code = 000000;
    var code;
    function getCheckCode() {
        let phone = document.getElementById('phone');
        let getCode = document.getElementById('getCode');
        if (phone.value.length == 0) {
            alert("请输入手机号码");
        } else {
            if (!(/^1[34578]\d{9}$/.test(phone.value))) {
                alert("手机号码有误，请重填")
            } else {
                code = 000000;
                page.getPasscode(phone.value).then(res => {
                    code = res;
                    t = setInterval(function () {
                        countdown()
                    }, 1000)
                    alert("获取验证码成功");
                    //获取验证码成功后调用倒计时函数
                    countdown();

                })

            }
        }

    }
    var time = 60;
    function countdown() {
        if (time == 0) {
            //这里时设置当时间到0的时候重新设置点击事件，并且默认time修改为60
            // $("#getCode").setAttribute("onclick", "getCheckCode()");
            $("#getCode").attr("onclick", "getCheckCode()")
            $("#getCode").text("获取验证码");
            time = 60;
            clearInterval(t);
        } else {
            //这里是显示时间倒计时的时候点击不生效
            $("#getCode").removeAttr("onclick");
            $("#getCode").text("重新发送" + time);
            time--;
        }
    }
    function checkPassCode() {
        let phone = document.getElementById('phone').value;
        let checkcode = document.getElementById('checkcode').value;
        if (checkcode.length > 0) {
            page.checkPassCode(phone, checkcode).then(res => {
                if (res.result == 'Success') {
                    alert("验证码正确")
                } else {
                    alert("请输入正确的验证码")
                }

            }).catch(err => {
                console.log(err.error_message)
            })
        }

    }
    function resetPassword() {
        let phone = document.getElementById('phone')
        let code = document.getElementById('checkcode')
        let password = document.getElementById('password')
        let checked = document.getElementById('checked')
        if (phone.value.length == 0) {
            alert("请输入手机号码");
        } else {
            if (!(/^1[34578]\d{9}$/.test(phone.value))) {
                alert("手机号码有误，请重填");
            } else {
                if (code.value.length == 0) {
                    alert("请输入验证码");
                } else {
                    //   if (code.value != code) {
                    //    alert("请输入正确的验证码")
                    //  } else {
                    //可以注册了
                    let params = {
                        phone: phone.value,
                        password: password.value,
                        pass_code: code.value,
                    }
                    page.resetPassword(params).then(res => {
                        if (res) {
                            alert('修改密码成功，正在跳转至登录页面！')
                            window.location = "login.html"
                        }
                    }).catch(err => {
                        alert('身份信息认证失败！')
                    })
                    //   }
                }
            }
        }
    }
    function changTab(e) {
        let that = e.target;
        $(that).parents('.box').addClass('active');
        $(that).parents('.box').siblings().removeClass('active');
        $(that).parents('.box').find('.icon').addClass('active');
        $(that).parents('.box').find('.icon').siblings().removeClass('active');
    }
</script>
